********************************************************************************
*Author: Sung Min Yun & John Ishiyama
*Department of Political Science, University of North Texas
*Article: Not All Stationary Bandits Are the Same :Ethnicity, Insurgency Goals, and Welfare Service Provision
*USE: Sung&IshiyamaMainFile
*Do File: Sung&IshiyamaDo
*About the description of the variables, please read our codebook carefully
********************************************************************************



use "C:\Users\Sung Min Yun\Desktop\UNTclass\Research\rebelgov\Albert Replication2\Replication File\Sung&IyhismaMainFile.dta"
* Use the above file we uploaded here
********************************************************************************

********************************************************************************
*Tables in tbe Main Article
********************************************************************************


*Table 3 (descriptive statistics)***********************************************
*Summarizing the variables
sum service type fgsup transins illegal tax dur comm strength terr gdppc cinc oil mt ethf dem ngo region
*calculating VIFs
*H1
logit service ib1.type fgsup transins illegal tax dur comm strength terr gdppc cinc oil mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3, vce(cluster actorid)
collin type fgsup transins illegal tax dur comm strength terr gdppc cinc oil mt ethf dem ngo region
*H2
logit service i.typeh2 fgsup transins illegal tax dur comm strength terr gdppc cinc oil mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3, vce(cluster actorid)
collin typeh2 fgsup transins illegal tax dur comm strength terr gdppc cinc oil mt ethf dem ngo region
********************************************************************************


********************************************************************************
*Table 4 & Figure 2
********************************************************************************


*Model 1
eststo:logit service ib1.type fgsup transins illegal tax dur comm strength terr peaceyrs peaceyrs2 peaceyrs3, vce(cluster actorid)
*Marginal Effect Plotted in Figure 2
margins type, vsquish
marginsplot, name(one) xlabel(0 "NONETHs" 1 "ETHNONSEPs" 2 "ETHSEPs") recast(bar) recastci(rcap) ciopts(lw(medthick) color(black)) graphregion(color(white))
*We further revised the plot manually after this command


*Model 2
eststo:logit service ib1.type gdppc cinc oil mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3, vce(cluster actorid)
*Marginal Effect Plotted in Figure 2
margins type, vsquish
marginsplot, name(two) xlabel(0 "NONETHs" 1 "ETHNONSEPs" 2 "ETHSEPs") recast(bar) recastci(rcap) ciopts(lw(medthick) color(black)) graphregion(color(white))


*Model 3
eststo:logit service ib1.type fgsup transins illegal tax dur comm strength terr gdppc cinc oil mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3, vce(cluster actorid)
*Marginal Effect Plotted in Figure 2
margins type, vsquish
marginsplot, name(three) xlabel(0 "NONETHs" 1 "ETHNONSEPs" 2 "ETHSEPs") recast(bar) recastci(rcap) ciopts(lw(medthick) color(black)) graphregion(color(white))


*Model 4
eststo:logit service ib1.type fgsup transins illegal tax dur comm strength peaceyrs peaceyrs2 peaceyrs3 if terr==1, vce(cluster actorid)
*Marginal Effect Plotted in Figure 2
margins type, vsquish
marginsplot, name(four) xlabel(0 "NONETHs" 1 "ETHNONSEPs" 2 "ETHSEPs") recast(bar) recastci(rcap) ciopts(lw(medthick) color(black)) graphregion(color(white))


*Model 5
eststo:logit service ib1.type gdppc cinc oil mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3 if terr==1, vce(cluster actorid)
*Marginal Effect Plotted in Figure 2
margins type, vsquish
marginsplot, name(five) xlabel(0 "NONETHs" 1 "ETHNONSEPs" 2 "ETHSEPs") recast(bar) recastci(rcap) ciopts(lw(medthick) color(black)) graphregion(color(white))


*Model 6
eststo:logit service ib1.type fgsup transins illegal tax dur comm strength gdppc cinc oil mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3 if terr==1, vce(cluster actorid)
*Marginal Effect Plotted in Figure 2
margins type, vsquish
marginsplot, name(six) xlabel(0 "NONETHs" 1 "ETHNONSEPs" 2 "ETHSEPs") recast(bar) recastci(rcap) ciopts(lw(medthick) color(black)) graphregion(color(white))


*Merging Models in Table 4
esttab using example.rtf, replace nogaps compress se scalars(ll aic bic chi2) star(* 0.10 ** 0.05 *** 0.01) label title(Table: Factors Related to Rebel Social Services)
eststo clear
*Combining Marginal Effects Plots
gr combine one two three four five six
********************************************************************************


********************************************************************************
*Table 4 & Figure 3*************************************************************
********************************************************************************
*Model 7
eststo:logit service i.typeh2 fgsup transins illegal tax dur comm strength terr peaceyrs peaceyrs2 peaceyrs3, vce(cluster actorid)
*Marginal Effect Plotted in Figure 3
margins typeh2, vsquish
marginsplot, name(seven) xlabel(0 "OTHERS" 1 "ETHSEPS" 2 "UNRECs") recast(bar) recastci(rcap) ciopts(lw(medthick) color(black)) graphregion(color(white))


*Model 8
eststo:logit service i.typeh2 gdppc cinc oil mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3, vce(cluster actorid)
*Marginal Effect Plotted in Figure 3
margins typeh2, vsquish
marginsplot, name(eight) xlabel(0 "OTHERS" 1 "ETHSEPS" 2 "UNRECs") recast(bar) recastci(rcap) ciopts(lw(medthick) color(black)) graphregion(color(white))


*Model 9
eststo:logit service i.typeh2 fgsup transins illegal tax dur comm strength terr gdppc cinc oil mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3, vce(cluster actorid)
*Marginal Effect Plotted in Figure 3
margins typeh2, vsquish
marginsplot, name(nine) xlabel(0 "OTHERS" 1 "ETHSEPS" 2 "UNRECs") recast(bar) recastci(rcap) ciopts(lw(medthick) color(black)) graphregion(color(white))


*Model 10
eststo: logit service i.typeh2 fgsup transins illegal tax dur comm strength peaceyrs peaceyrs2 peaceyrs3 if terr==1, vce(cluster actorid)
*Marginal Effect Plotted in Figure 3
margins typeh2, vsquish
marginsplot, name(ten) xlabel(0 "OTHERS" 1 "ETHSEPS" 2 "UNRECs") recast(bar) recastci(rcap) ciopts(lw(medthick) color(black)) graphregion(color(white))


*Model 11
eststo:logit service i.typeh2 gdppc cinc oil mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3 if terr==1, vce(cluster actorid)
*Marginal Effect Plotted in Figure 3
margins typeh2, vsquish
marginsplot, name(eleven) xlabel(0 "OTHERS" 1 "ETHSEPS" 2 "UNRECs") recast(bar) recastci(rcap) ciopts(lw(medthick) color(black)) graphregion(color(white))


*Model 12
eststo:logit service i.typeh2 fgsup transins illegal tax dur comm strength gdppc cinc oil mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3 if terr==1, vce(cluster actorid)
*Marginal Effect Plotted in Figure 3
margins typeh2, vsquish
marginsplot, name(twelve) xlabel(0 "OTHERS" 1 "ETHSEPS" 2 "UNRECs") recast(bar) recastci(rcap) ciopts(lw(medthick) color(black)) graphregion(color(white))


*Merging Models in Table 5
esttab using example.rtf, replace nogaps compress se scalars(ll aic bic chi2) star(* 0.10 ** 0.05 *** 0.01) label title(Table: Factors Related to Rebel Social Services)
eststo clear
*Combining Marginal Effects Plots
gr combine seven eight nine ten eleven twelve
********************************************************************************


********************************************************************************
********************************************************************************
*Tables in Online Appendix
********************************************************************************


********************************************************************************
*Table A1
********************************************************************************
*Model A1
eststo:logit service ib1.type fgsup transins illegal tax dur comm resource criminal terr gdppc cinc mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3, vce(cluster actorid)


*Model A2
eststo:logit service ib1.type fgsup transins illegal tax dur comm resource criminal gdppc cinc mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3 if terr==1, vce(cluster actorid)


*Model A3
eststo:logit service i.typeh2 fgsup transins illegal tax dur comm resource criminal terr gdppc cinc mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3, vce(cluster actorid)


*Model A4
eststo:logit service i.typeh2 fgsup transins illegal tax dur comm resource criminal gdppc cinc mt ethf dem ngo i.region peaceyrs peaceyrs2 peaceyrs3 if terr==1, vce(cluster actorid)


*Merging Models in Table A1
esttab using example.rtf, replace nogaps compress se scalars(ll aic bic chi2) star(* 0.10 ** 0.05 *** 0.01) drop(*.region) label title(Table: Factors Related to Rebel Social Services)
eststo clear
********************************************************************************


********************************************************************************
*Table A2
********************************************************************************


********************************************************************************
*Model A5
sureg (secju ib1.type fgsup transins illegal tax dur comm strength terr gdppc cinc oil mt ethf dem ngo i.region i.Year) (welfra ib1.type fgsup transins illegal tax dur comm strength terr gdppc cinc oil mt ethf dem ngo i.region i.Year)
*Calculating the clustered S.E.
eststo:suregr, cluster(actorid) minus(1) noheader


*Model A6
sureg (secju ib1.type fgsup transins illegal tax dur comm strength gdppc cinc oil mt ethf dem ngo i.region i.Year) (welfra ib1.type fgsup transins illegal tax dur comm strength gdppc cinc oil mt ethf dem ngo i.region i.Year) if terr==1
*Calculating the clustered S.E.
eststo:suregr, cluster(actorid) minus(1) noheader


*Model A7
sureg (secju i.typeh2 fgsup transins illegal tax dur comm strength terr gdppc cinc oil mt ethf dem ngo i.region i.Year) (welfra i.typeh2 fgsup transins illegal tax dur comm strength terr gdppc cinc oil mt ethf dem ngo i.region i.Year)
*Calculating the clustered S.E.
eststo:suregr, cluster(actorid) minus(1) noheader


*Model A8
sureg (secju i.typeh2 fgsup transins illegal tax dur comm strength gdppc cinc oil mt ethf dem ngo i.region i.Year) (welfra i.typeh2 fgsup transins illegal tax dur comm strength gdppc cinc oil mt ethf dem ngo i.region i.Year) if terr==1
*Calculating the clustered S.E.
eststo:suregr, cluster(actorid) minus(1) noheader


*Merging Models in Table A2
esttab using example.rtf, replace nogaps compress se scalars(ll aic bic chi2) star(* 0.10 ** 0.05 *** 0.01) drop(*.Year *.region) label title(Table: Factors Related to Rebel Social Services)
eststo clear
********************************************************************************


********************************************************************************
*Table A3
********************************************************************************
*Model A9
sureg (secju ib1.type fgsup transins illegal tax dur comm resource criminal terr gdppc cinc mt ethf dem ngo i.region i.Year) (welfra ib1.type fgsup transins illegal tax dur comm resource criminal terr gdppc cinc mt ethf dem ngo i.region i.Year)
*Calculating the clustered S.E.
eststo:suregr, cluster(actorid) minus(1) noheader


*Model A10
sureg (secju ib1.type fgsup transins illegal tax dur comm resource criminal gdppc cinc mt ethf dem ngo i.region i.Year) (welfra ib1.type fgsup transins illegal tax dur comm resource criminal gdppc cinc mt ethf dem ngo i.region i.Year) if terr==1
*Calculating the clustered S.E.
eststo:suregr, cluster(actorid) minus(1) noheader


*Model A11
sureg (secju i.typeh2 fgsup transins illegal tax dur comm resource criminal terr gdppc cinc mt ethf dem ngo i.region i.Year) (welfra i.typeh2 fgsup transins illegal tax dur comm resource criminal terr gdppc cinc mt ethf dem ngo i.region i.Year)
*Calculating the clustered S.E.
eststo:suregr, cluster(actorid) minus(1) noheader


*Model A12
sureg (secju i.typeh2 fgsup transins illegal tax dur comm resource criminal gdppc cinc mt ethf dem ngo i.region i.Year) (welfra i.typeh2 fgsup transins illegal tax dur comm resource criminal gdppc cinc mt ethf dem ngo i.region i.Year) if terr==1
*Calculating the clustered S.E.
eststo:suregr, cluster(actorid) minus(1) noheader


*Merging Models in Table A3
esttab using example.rtf, replace nogaps compress se scalars(ll aic bic chi2) star(* 0.10 ** 0.05 *** 0.01) drop(*.Year *.region) label title(Table: Factors Related to Rebel Social Services)
eststo clear
********************************************************************************
*end****************************************************************************
